<template>
  <div class="homeborder">
    <div class="search-contents">
      <div class="search-input">
        <div class="title">用户名</div>
        <a-input
          v-model:value="username"
          style="width: 800px"
          class="a-inp"
          placeholder="请输入用户名"
        />
      </div>
      <div class="search-btn">
        <a-button type="primary" ghost class="search-btn-item">搜索</a-button>
        <a-button class="search-btn-item">重置</a-button>
        <a-button type="primary" class="add-btn">导入yaml文件</a-button>
      </div>
    </div>
    <div class="tcontents">
      <a-table
        :columns="columns"
        :data-source="data"
        :pagination="{ pageSize: 6 }"
      >
        <template #bodyCell="{ column }">
          <template v-if="column.dataIndex === 'operation'">
            <a-button type="primary" danger>删除</a-button>
            <a-button type="link" @click="showModalPreview">预览</a-button>
          </template>
        </template>
      </a-table>
    </div>
    <a-modal
      v-model:open="openPreview"
      okText="确定"
      cancelText="取消"
      title="预览"
      @ok="handleOkPreview"
    >
      <div class="search-item-preview">
        <div class="title-preview">资源包名称</div>
        <a-input v-model:value="name" class="a-inp-preview" />
      </div>
      <div class="search-item-preview">
        <div class="title-preview">版本</div>
        <a-input v-model:value="name" class="a-inp-preview" />
      </div>
      <div class="search-item-preview-img">
        <div class="title-preview-img">登录logo</div>
        <div class="imgcontents">
          <div class="imgself">
            <img :src="Avatar" alt="Avatar" />
          </div>
          <div class="expAnddesc">
            <a class="example">查看示例</a>
            <div class="desc">建议上传1M以下的格式</div>
          </div>
        </div>
      </div>
      <div class="search-item-preview-img">
        <div class="title-preview-img">徽标logo</div>
        <div class="imgcontents">
          <div class="imgself">
            <img :src="Avatar" alt="Avatar" />
          </div>
          <div class="expAnddesc">
            <a class="example">查看示例</a>
            <div class="desc">建议上传1M以下的格式</div>
          </div>
        </div>
      </div>
      <div class="search-item-preview-img">
        <div class="title-preview-img">徽标logo</div>
        <div class="imgcontents">
          <div class="imgself">
            <img :src="Avatar" alt="Avatar" />
          </div>
          <div class="expAnddesc">
            <a class="example">查看示例</a>
            <div class="desc">建议上传1M以下的格式</div>
          </div>
        </div>
      </div>
      <div class="search-item-preview-img">
        <div class="title-preview-img">徽标logo</div>
        <div class="imgcontents">
          <div class="imgself">
            <img :src="Avatar" alt="Avatar" />
          </div>
          <div class="expAnddesc">
            <a class="example">查看示例</a>
            <div class="desc">建议上传1M以下的格式</div>
          </div>
        </div>
      </div>
    </a-modal>
  </div>
</template>

<script setup>
import { reactive, ref } from "vue";
import { useRouter } from "vue-router"; // 引入 useRouter
// 这是一集级视图查看详情
const username = ref("");
// 预览
import Avatar from "@/assets/卡通头像-copy.png";
// 预览部分
const openPreview = ref(false);
const showModalPreview = () => {
  openPreview.value = true;
};
const handleOkPreview = (e) => {
  console.log(e);
  openPreview.value = false;
};

const value1 = ref("V1");
const handleChange = (value) => {
  console.log(`selected ${value}`);
};
const columns = [
  {
    title: "资源包版本",
    dataIndex: "version",
  },
  {
    title: "资源包名称",
    dataIndex: "name",
  },

  {
    title: "创建人",
    dataIndex: "founder",
  },
  {
    title: "创建时间",
    dataIndex: "fondtime",
  },

  {
    title: "操作",
    dataIndex: "operation",
    fixed: "right",
    width: 200,
  },
];
const data = [
  {
    key: 1,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 2,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 3,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 4,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 5,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 6,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 7,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
  {
    key: 8,
    version: "v1",
    name: "图片资源包",
    founder: "zzw",
    fondtime: "2023-12-03 11:09:09",
  },
];
</script>
<style lang="scss" scoped>
.homeborder {
  width: 95%;
  height: 100%;
  position: fixed;
  background-size: 100% 100%;
  margin-left: 1%;
}
.tcontents {
  width: 86%;
}
.add-btn {
  /* margin: 10px 0; */
}
.title {
  width: 100px;
  height: 35px;

  line-height: 25px;
  text-align: center;
  border: 1px solid #d9d9d9;
  background-color: #f8fafb;
  padding: 5px;
}
.a-inp {
  border-radius: 3px;
}
.search-btn {
  display: flex;
  margin-left: 26px;
}
.search-btn-item {
  margin: 0 5px;
}
.search-contents {
  display: flex;
  margin: 20px 0;
}
.search-input {
  height: 35px;
  display: flex;
}
.search-item-preview {
  display: flex;
  width: 100%;
  height: 35px;
  padding: 0;
  margin: 10px 5px;
}
.title-preview {
  width: 100px;
  line-height: 25px;
  text-align: center;
  border: 1px solid #d9d9d9;
  background-color: #f8fafb;
  padding: 5px;
}
.title-preview-img {
  width: 84px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  border: 1px solid #d9d9d9;
  background-color: #f8fafb;
}
.search-item-preview-img {
  display: flex;
  width: 100%;
  height: 50px;
  padding: 0;
  margin: 10px 5px;
}
.a-inp-preview {
  border-radius: 3px;
}
.imgcontents {
  display: flex;
  margin: 0 10px;
}
.imgself {
  width: 50px;
  height: 50px;
  img {
    width: 50px;
    height: 50px;
  }
}
.expAnddesc {
  margin: 0 15px;
  height: 50px;
}
</style>
